package org.ft.web;

import com.ft.security.SecurityConstants;
import com.ft.security.model.JwtToken;
import com.ft.security.service.IAuthService;
import com.ft.security.service.dto.LoginUserInput;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiSort;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @copyright (C), 2015-2019, XXX有限公司
 * @fileName: AuthController
 * @author: 李阳
 * @date: 2019/7/9 15:17
 * @description:
 * @history: <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
@RestController
@Api(value = "oauth", tags = "授权模块")
@ApiSort(-1000)
@AllArgsConstructor
public class AuthController {

    private IAuthService authService;

    @ApiOperation(value = "登录")
    @RequestMapping(value = SecurityConstants.OAUTH_TOKEN_LOGIN_URL, method = RequestMethod.POST)
    public JwtToken login(@RequestHeader("tenantId") Long tenantId, @RequestBody LoginUserInput input) {
        return authService.login(input.getUserName(),input.getPassword(),tenantId);
    }
}
